package dfl.bysj.controller;


import dfl.bysj.exception.Assert;
import dfl.bysj.handler.NoAuth;
import dfl.bysj.result.R;
import dfl.bysj.result.ResponseEnum;
import dfl.bysj.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author DFL
 * @since 2022-04-26
 */
@RestController
@RequestMapping("/grade")
public class GradeController {
    GradeService gradeService;

    @Autowired
    public void setGradeService(GradeService gradeService) {
        this.gradeService = gradeService;
    }

    @NoAuth
    @GetMapping("/main/grade")
    public R main_grade(String graId){
        Assert.notNull(graId, ResponseEnum.ERROR);
        return R.ok().data("grade", gradeService.getById(graId));
    }
    @GetMapping("/list")
    public R list(){
        return R.ok().data("list", gradeService.getALLGrade());
    }

    @GetMapping("/acaName")
    public R acaName(String acaName){
        return R.ok().data("list",gradeService.getALLGradeByAcaName(acaName));
    }
}

